# 1.导包
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

# 2.创建浏览器驱动对象
# Firefox浏览器:
# driver = webdriver.Firefox()
# Chrome浏览器:
path = r"D:\Programs\Python\Python313\chromedriver.exe"
ser = Service(executable_path = path)
driver = webdriver.Chrome(service = ser)
# 使用Edge浏览器,不需要安装驱动
# driver = webdriver.Edge ()
# 3.打开Web页面
driver.get("http://121.43.169.97:8848/pageA.html")
# driver.find_element(by=By.XPATH, value="/html/body/div/fieldset/form/p[1]/input").send_keys("admin")
# driver.find_element(by=By.XPATH, value="//p[2]/input").send_keys("123456")
# driver.find_element(by=By.XPATH, value="//*[@name='usernameA']").send_keys("admin")
driver.find_element(by=By.CSS_SELECTOR, value="#userA").send_keys("admin")
driver.find_element(by=By.CSS_SELECTOR, value="[name='passwordA']").send_keys("123456")
driver.find_element(by=By.CSS_SELECTOR, value=".telA").send_keys("13400000000")
# 当使用css选择器定位元素时，使用class选择器时,有多个class值,则将多个class值之前都加上.连接起来
driver.find_element(by=By.CSS_SELECTOR, value=".emailA.dzyxA").send_keys("123456@qq.com")
time.sleep(5)
driver.find_element(by=By.CSS_SELECTOR, value="button").click()
# driver.find_element(by=By.XPATH, value="//*[contains(@id='cancelA')]").click()
# 4.暂停
time.sleep(5)
# 5.关闭浏览器驱动对象
driver.quit()